<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>设置我的密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <th:block th:include="common.html :: source"></th:block>
    <link href="/static/layui/css/layui.css" rel="stylesheet">
    <link href="/static/layui/css/layuiAdmin.css" rel="stylesheet">
</head>
<style>
    .layui-col-space15>* {
        padding: 15px;
    }
    .layui-form-label{
        width: 100px;
    }
</style>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改密码</div>
                <div class="layui-card-body" pad15>

                    <form class="layui-form" lay-filter="" action="/manage/updatePassWord" method="post">
                        <div class="layui-form-item">
                            <label class="layui-form-label">当前密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="oldPassword" id="oldPassword" lay-verify="required" lay-verType="tips" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password" lay-verify="required" lay-verType="tips" autocomplete="off" minlength="6" maxlength="16" id="LAY_password" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">6到16个字符</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="repassword" id="repassword" lay-verify="required" lay-verType="tips" minlength="6" maxlength="16" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="updatePwd">确认修改</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>

                    </form>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/static/layui/layui.js"></script>
<script>
    layui.use(['layer', 'form'], function () {
        var layer = layui.layer;
        var form = layui.form;
        form.on('submit(updatePwd)', function () {
            $.post({
                url: '/manage/updatePassWord',
                data: {
                    "oldPassword": $("#oldPassword").val(),
                    "password": $("#LAY_password").val(),
                    "repassword": $("#repassword").val(),
                },
                success: function (data) {

                    if (data.code === 0) {
                        layer.msg('修改成功！', {icon: 6, offset: "20,30", time: 2000});//提示框

                    } else {
                        layer.msg(data.msg, {icon: 5, offset: "20,30", time: 2000});//提示框
                    }
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);//关闭弹出层
                        parent.location.reload();//重新加载父页面表格
                    }, 2100);
                }
            });
            return false;
        });
    });

</script>
</body>
</html>